package com.crazy.rest;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author zhaochaofeng
 * @version 1.0
 * @date 2020/11/18 13:58
 */
@ApiModel("Rest基础返回结果")
public abstract class BaseResult {
    public static final int FAILED = 0;
    public static final int SUCCESS = 1;
    public static final int ERROR = -1;
    @ApiModelProperty(
            value = "REST请求状态结果【成功 1 | 失败 0 | 错误 -1】",
            dataType = "int",
            allowableValues = "1,0,-1"
    )
    protected int status;
    @ApiModelProperty(
            value = "REST请求返回消息",
            dataType = "String"
    )
    protected String message;

    public BaseResult() {
    }

    public int getStatus() {
        return this.status;
    }

    public String getMessage() {
        return this.message;
    }

    public void setStatus(final int status) {
        this.status = status;
    }

    public void setMessage(final String message) {
        this.message = message;
    }

    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof BaseResult)) {
            return false;
        } else {
            BaseResult other = (BaseResult)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getStatus() != other.getStatus()) {
                return false;
            } else {
                Object this$message = this.getMessage();
                Object other$message = other.getMessage();
                if (this$message == null) {
                    if (other$message != null) {
                        return false;
                    }
                } else if (!this$message.equals(other$message)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof BaseResult;
    }

    @Override
    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        result = result * 59 + this.getStatus();
        Object $message = this.getMessage();
        result = result * 59 + ($message == null ? 43 : $message.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "BaseResult(status=" + this.getStatus() + ", message=" + this.getMessage() + ")";
    }
}
